package com.easy.controller;

import com.easy.bean.Orderdetails;
import com.easy.service.IOrderdetailsService;
import com.easy.util.LayData;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("orderdetails")
public class OrderdetailsController {
    @Autowired
    IOrderdetailsService orderdetailsService;

    @RequestMapping("list")
    @ResponseBody
    public LayData getOrderdetailsList(Page page, String text){
        List<Orderdetails> list=orderdetailsService.getOrderdetailsList(page,text);
        int count=orderdetailsService.OrderdetailsCount(text);
        return new LayData(count,list);
    }

    @RequestMapping("delete")
    @ResponseBody
    public int deleteOrderdetails(int orderid,int proid){
        return orderdetailsService.deleteOrderdetails(orderid,proid);
    }

    @RequestMapping("add")
    @ResponseBody
    public int addOrderdetails(Orderdetails orderdetails){
        return orderdetailsService.addOrderdetails(orderdetails);
    }

    @RequestMapping("insert")
    @ResponseBody
    public int insertOrderdetails(int userid,int orderid){
        return orderdetailsService.insertOrderdetails(userid,orderid);
    }

    @RequestMapping("edit")
    @ResponseBody
    public int editOrderdetails(Orderdetails orderdetails){
        return orderdetailsService.editOrderdetails(orderdetails);
    }

    @RequestMapping("get")
    @ResponseBody
    public List<Orderdetails> getOrderdetailsById(int orderid){
        return orderdetailsService.getOrderdetailsById(orderid);
    }

    @RequestMapping("sum")
    @ResponseBody
    public double totalOrderdetailsPrice(int orderid){
        return orderdetailsService.totalOrderdetailsPrice(orderid);
    }

}
